package com.bm.server.service.impl;

import com.bm.server.util.Rutils;
import com.bm.server.vo.R;
import com.bm.server.dao.RandomUserDao;
import com.bm.server.entity.UserInfo;
import com.bm.server.service.intf.RandomUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class RandomUserServiceImpl implements RandomUserService {
    @Resource
    private RandomUserDao dao;

    @Override
    public R randomUser(long uid) {
        UserInfo userInfo = new UserInfo();
        if (uid > 0) {
            while (true) {
                List<UserInfo> userInfos = dao.randomUser(uid);
                for (UserInfo info : userInfos) {
                    if (info.getUid() != uid) {
                        return Rutils.ok(dao.randomUser(uid));
                    }
                }
            }
          

        }
        return Rutils.fail();

    }

}            
    
